#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=2e5+5;
int n,a[Maxn],b[Maxn];
int ans[Maxn];
int stk[Maxn],len;
int l[Maxn],r[Maxn];
inline void solve1(){
	for(int i=1;i<=n;i++){
		while(len&&a[stk[len]]>=a[i])len--;
		l[i]=stk[len]+1;
		stk[++len]=i;
	}len=0;
	stk[0]=n+1;
	for(int i=n;i;i--){
		while(len&&a[stk[len]]>=a[i])len--;
		r[i]=stk[len]-1;
		stk[++len]=i;
	}
	for(int i=1;i<=n;i++){
		ans[r[i]-l[i]+1]=min(ans[r[i]-l[i]+1],a[i]);
	}
	for(int i=n-1;i;i--)ans[i]=min(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]-1);
}
inline void solve2(){
	for(int i=1;i<=n;i++){
		while(len&&a[stk[len]]>=a[i])len--;
		l[i]=stk[len]+1;
		stk[++len]=i;
	}len=0;
	stk[0]=n+1;
	for(int i=n;i;i--){
		while(len&&a[stk[len]]>=a[i])len--;
		r[i]=stk[len]-1;
		stk[++len]=i;
	}
	for(int i=1;i<=n;i++)ans[i]=0;
	for(int i=1;i<=n;i++){
		ans[r[i]-l[i]+1]=max(ans[r[i]-l[i]+1],a[i]);
	}
	for(int i=n-1;i;i--)ans[i]=max(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)printf("%lld\n",(int)1e9-ans[i]);
}
signed main(){
	freopen("min.in","r",stdin);
	freopen("min.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)ans[i]=1e18;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	if(n<=5000){
		for(int l=1;l<=n;l++){
			int mn1=a[l],mn2=b[l];
			for(int r=l;r<=n;r++){
				mn1=min(mn1,a[r]);
				mn2=min(mn2,b[r]);
				ans[r-l+1]=min(ans[r-l+1],abs(mn1-mn2));
			}
		}
		for(int i=1;i<=n;i++)printf("%lld\n",ans[i]);
		return 0;
	}
	int sub1=1,sub2=1;
	for(int i=1;i<=n;i++)sub1&=(b[i]==1),sub2&=(b[i]==(int)1e9);
	if(sub1)solve1(),exit(0);
	if(sub2)solve2(),exit(0);
	return 0;
}

